<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>{$Think.config.site.title} - 更新服务器地址</title>
    <meta name="keywords" content="{$Think.config.site.keywords}">
    <meta name="description" content="{$Think.config.site.description}">
    <link href="{$Think.config.site.resource_url}css/bootstrap.min.css?v=3.3.6" rel="stylesheet">
    <link href="{$Think.config.site.resource_url}css/font-awesome.css?v=4.4.0" rel="stylesheet">
    <link href="{$Think.config.site.resource_url}css/animate.css" rel="stylesheet">
    <link href="{$Think.config.site.resource_url}css/plugins/chosen/chosen.css" rel="stylesheet">
    <link href="{$Think.config.site.resource_url}css/plugins/awesome-bootstrap-checkbox/awesome-bootstrap-checkbox.css" rel="stylesheet">
    <link href="{$Think.config.site.resource_url}css/style.css?v=4.1.0" rel="stylesheet">
</head>
<body class="gray-bg">
<div class="wrapper wrapper-content animated fadeInRight">
    <div class="row">

        <div class="col-sm-12">
            <div class="ibox float-e-margins">
                <div class="ibox-content">
                    <form class="form-horizontal m-t" id="commentForm" novalidate="novalidate">
                        <div class="form-group">
                            <label class="col-sm-3 control-label">{:lang('选择类型')}：</label>
                            <div class="col-sm-8">
                                <div class="input-group">
                                    <select data-placeholder="请选择类型..." class="chosen-select  form-control" id="types" name="types" style="width:100%;" tabindex="10" required>
                                        <option value="">{:lang('选择类型')}</option>
                                        <option value="1" hassubinfo="true" {if condition="$up['types'] eq 1"} selected="selected" {/if}>request</option>
                                        <option value="2" hassubinfo="true" {if condition="$up['types'] eq 2"} selected="selected" {/if}>socket</option>
                                        <option value="3" hassubinfo="true" {if condition="$up['types'] eq 3"} selected="selected" {/if}>uploadFile</option>
                                        <option value="4" hassubinfo="true" {if condition="$up['types'] eq 4"} selected="selected" {/if}>downloadFile</option>
                                    </select>
                                </div>
                                <input type="hidden" value="{$up.id}" name="id">
                            </div>
                        </div>
                        
                        <div class="form-group">
                            <label class="col-sm-3 control-label">{:lang('网址')}：</label>
                            <div class="col-sm-8">
                                <input id="addr" type="text" class="form-control" name="addr" required="" value="{$up['addr']}" aria-required="true" >
                           </div>
                        </div>
                        
                        <div class="form-group">
                            <div class="col-sm-4 col-sm-offset-3">
                                <button class="btn btn-primary" type="button" id="onbtn">{:lang('提交')}</button>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>
    <!-- 全局js -->
    <script src="{$Think.config.site.resource_url}js/jquery.min.js?v=2.1.4"></script>
    <script src="{$Think.config.site.resource_url}js/bootstrap.min.js?v=3.3.6"></script>
    <!-- 自定义js -->
    <script src="{$Think.config.site.resource_url}js/content.js?v=1.0.0"></script>
    <!-- jQuery Validation plugin javascript-->
    <script src="{$Think.config.site.resource_url}js/plugins/validate/jquery.validate.min.js"></script>
    <script src="{$Think.config.site.resource_url}js/plugins/validate/messages_zh.min.js"></script>
    <script src="{$Think.config.site.resource_url}js/demo/form-validate-demo.js"></script>
    <script src="{$Think.config.site.resource_url}js/plugins/chosen/chosen.jquery.js"></script>
    <script src="{$Think.config.site.resource_url}js/plugins/layer/layer.js"></script>
    <script type="text/javascript">
        $(function(){
            $('.chosen-select').chosen();
        });

    </script>
    <script type="text/javascript">
        $('#onbtn').click(function(){
            var formdata = $('#commentForm').serialize();
            var types = $('#types').val();
            var addr = $('#addr').val();
            if(types==''){
                $("#types").attr('placeholder',"{:lang('请选择类型')}");
                $("#types").focus();
                return false;
            }
            if(addr==''){
                $("#addr").attr('placeholder',"{:lang('请输入服务器地址')}");
                $("#addr").focus();
                return false;
            }
            
            $.ajax({
                type : 'POST',
                url  : '<?php echo \think\Request::instance()->root(); ?>/ausadmin/System/serviceaddr',
                dataType : 'json',
                data : formdata,
                async : false,
                success : function(result){
                    if(0 == result.code){
                        layer.msg(result.msg, {icon: 1});
                        parent.location.reload();
                    }else{
                        layer.msg(result.msg, {icon: 5});
                    }
                },
                error : function(){
                    layer.msg("{:lang('服务器错误！请稍后重试')}", {icon: 2});
                }
            }); 
        });
    </script>
</body>
</html>